import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

/*
 *@Student 张策
 */
public class Text2 {
    public static void main(String[] args) throws Exception {
        ObjectOutputStream ooc = new ObjectOutputStream(new FileOutputStream("e:\\Text4.dat"));
        ooc.writeInt(100);
        ooc.writeChar('a');
        ooc.writeUTF("错把白云揉碎");
        ooc.writeObject(new Dog("No1",10));
    }
}
class Dog implements Serializable {
    private String name;
    private  int age;
    private Cat cat=new Cat();

    public Dog(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
               ", cat=" + cat +
                '}';
    }
}
class Cat implements Serializable{

}